//
//  HypnosisViewController.m
//  BigNerdRanchGuidesC7-ViewControllers_HypnoTime
//
//  Created by Rafal on 4/7/13.
//  Copyright (c) 2013 Rafal Rebacz. All rights reserved.
//

#import "HypnosisViewController.h"

@implementation HypnosisViewController


- (id)init
{
    self = [super init];
    if (self) {
        UITabBarItem* tbi = [self tabBarItem];
        [tbi setTitle:@"Hypnosis"];
    }
    return self;
}

- (void)loadView
{
    CGRect frame = [[UIScreen mainScreen] bounds];
    _hypnosisView = [[HypnosisView alloc] initWithFrame:frame];
    
    NSArray* items = [NSArray arrayWithObjects:@"Red", @"Green", @"Blue", nil];
    _segmentedCtrl = [[UISegmentedControl alloc] initWithItems:items];
    _segmentedCtrl.frame = CGRectMake(60, 0, 200, 20);
    _segmentedCtrl.selectedSegmentIndex = 0;
    [_segmentedCtrl addTarget:self action:@selector(valueChanged:) forControlEvents:UIControlEventValueChanged];

    [_hypnosisView addSubview:_segmentedCtrl];
    
    self.view = _hypnosisView;
}

- (void)valueChanged:(UISegmentedControl*)segmentedCtrl
{
    if(segmentedCtrl.selectedSegmentIndex == 0)
        _hypnosisView.circleColor = [UIColor redColor];
    else if(segmentedCtrl.selectedSegmentIndex == 1)
        _hypnosisView.circleColor = [UIColor greenColor];
    else
        _hypnosisView.circleColor = [UIColor blueColor];
}

@end
